package com.glorysoft.xztpda.bindingadapter

import android.graphics.Color
import android.util.SparseArray
import android.view.View
import android.widget.CheckBox
import android.widget.LinearLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.glorysoft.xztpda.R
import com.glorysoft.xztpda.base.DataBindBaseViewHolder
import com.glorysoft.xztpda.databinding.ItemEdcDataBinding
import com.glorysoft.xztpda.databinding.ItemMainBinding
import com.glorysoft.xztpda.entity.EdcDataEDCSETLISTEDCSETBINLINELIST
import com.glorysoft.xztpda.entity.LotInfoEntity

/**
 * FileName: LastLotAdapter
 * Author: XJH
 * Date: 2022/5/12 18:30
 * Description:
 * History:
 */
class DataCollectionAdapter(data: MutableList<EdcDataEDCSETLISTEDCSETBINLINELIST>?,val listener : OnEditClickListener) :
    BaseQuickAdapter<EdcDataEDCSETLISTEDCSETBINLINELIST, DataBindBaseViewHolder>(
        R.layout.item_edc_data,
        data
    ) {

    override fun convert(
        helper: DataBindBaseViewHolder?,
        item: EdcDataEDCSETLISTEDCSETBINLINELIST?
    ) {
        val binding = helper!!.getDataBinding() as ItemEdcDataBinding?
        binding?.edcItem = item
        binding?.etValue?.onFocusChangeListener =
            View.OnFocusChangeListener { v, hasFocus ->
                if (hasFocus){
                    listener.onEditClick(helper.adapterPosition)
                }
            }
        binding?.executePendingBindings()
    }

    interface OnEditClickListener{
        fun onEditClick(position : Int)
    }
}